home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-06 / an103x.zip / WAKEUP.C < prev   
C/C++ Source or Header  |  1991-04-09  |  2KB  |  77 lines

  1. /*****************************************************************************
  2. * WAKEUP.C
  3. *
  4. * 91-02-08 Matt Hagen, Novell, Inc.
  5. *****************************************************************************/
  6.  
  7. #include <nwtypes.h>
  8. #include <conio.h>
  9. #include <process.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <errno.h>
  13.  
  14. void PollRoutine(
  15.     void);
  16.  
  17. /*****************************************************************************
  18. * main
  19. *****************************************************************************/
  20.  
  21. main(
  22.     int argc,
  23.     char *argv[])
  24. {
  25.     int ccode;
  26.     int pollThread;
  27.  
  28.     pollThread=BeginThread(PollRoutine,NULL,NULL,NULL);
  29.     if(pollThread==EFAILURE)
  30.         Breakpoint(1);
  31.  
  32.     ThreadSwitch();
  33.  
  34.     while(TRUE)
  35.     {
  36.         delay(5000);
  37.         ccode=ResumeThread(pollThread);
  38.  
  39.         switch(ccode)
  40.         {
  41.             case ESUCCESS:
  42.                 ConsolePrintf("  Main thread: I woke up Poll thread.\n");
  43.                 break;
  44.  
  45.             case EWRNGKND:
  46.                 ConsolePrintf("  Main thread: Poll thread already awake.\n");
  47.                 break;
  48.  
  49.             case EBADHNDL:
  50.                 ConsolePrintf("  Main thread: Bad handle.\n");
  51.                 break;
  52.  
  53.             default:
  54.                 ConsolePrintf("  Main thread: ResumeThread() error = %d.\n",ccode);
  55.                 break;
  56.         }
  57.     }
  58. }
  59.  
  60. /*****************************************************************************
  61. * PollRoutine
  62. *****************************************************************************/
  63.  
  64. void PollRoutine(
  65.     void)
  66. {
  67.     while(TRUE)
  68.     {
  69.         delay(20000);
  70.  
  71.         ConsolePrintf("  Poll thread: I woke up.\n");
  72.     }
  73. }
  74.  
  75. /****************************************************************************/
  76. /****************************************************************************/
  77.